Test Series - Data Structure

Test Number 73/115

Q:  2-3 tree is a specific form of _________
A. B – tree
B. B+ – tree
C. AVL tree
D. Heap
Solution: The 2-3 trees is a balanced tree. It is a specific form the B – tree. It is B – tree of order 3, where every node can have two child subtrees and one key or 3 child subtrees and two keys.
Q: The height of 2-3 tree with n elements is ______
A. between (n/2) and (n/3)
B. (n/6)
C. between (n) and log2(n + 1)
D. between log3(n + 1) and log2(n + 1)
Solution: The number of elements in a 2-3 tree with height h is between 2h – 1 and 3h – 1. Therefore, the 2-3 tree with n elements will have the height between log3(n + 1) and log2(n + 1).
Q: Which of the following the BST is isometric with the 2-3 tree?
A. Splay tree
B. AA tree
C. Heap
D. Red – Black tree
Solution: AA tree is isometric of the 2-3 trees. In an AA tree, we store each node a level, which is the height of the corresponding 2-3 tree node. So, we can convert a 2-3 tree to an AA tree.
Q: Which of the following data structure can provide efficient searching of the elements?
A. unordered lists
B. binary search tree
C. treap
D. 2-3 tree
Solution: The average case time for lookup in a binary search tree, treap and 2-3 tree is O(log n) and in unordered lists it is O(n). But in the worst case, only the 2-3 trees perform lookup efficiently as it takes O(log n), while others take O(n).
Q: LLRB maintains 1-1 correspondence with 2–3 trees.
A. True
B. False
C. none
D. ...
Solution: LLRB (Left Leaning Red Black tree)is the data structure which is used to implement the 2-3 tree with very basic code. The LLRB is like the 2-3 tree where each node has one key and two links. In LLRB the 3-node is implemented as two 2-nodes connected by the red link that leans left. Thus, LLRB maintains 1-1 correspondence with 2–3 tree.data-structures-questions-answers-2-3-tree-q7
Q: Which of the following is not true about the 2-3 tree?
A. all leaves are at the same level
B. it is perfectly balanced
C. postorder traversal yields elements in sorted order
D. it is B-tree of order 3
Solution: In a 2-3 tree, leaves are at the same level. And 2-3 trees are perfectly balanced as every path from root node to the null link is of equal length. In 2-3 tree in-order traversal yields elements in sorted order.
Q: AVL trees provide better insertion the 2-3 trees.
A. True
B. False
C. none
D. ...
Solution: Insertion in AVL tree and 2-3 tree requires searching for proper position for insertion and transformations for balancing the tree. In both, the trees searching takes O(log n) time, but rebalancing in AVL tree takes O(log n), while the 2-3 tree takes O(1). So, 2-3 tree provides better insertions.
Q: Which of the following is false?
A. 2-3 tree requires less storage than the BST
B. lookup in 2-3 tree is more efficient than in BST
C. 2-3 tree is shallower than BST
D. 2-3 tree is a balanced tree
Solution: Search is more efficient in the 2-3 tree than in BST. 2-3 tree is a balanced tree and performs efficient insertion and deletion and it is shallower than BST. But, 2-3 tree requires more storage than the BST.

You Have Score    /8